home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995 February: Tool Chest / Dev.CD Feb 95 / Dev.CD Feb 95.toast / Sample Code / Snippets / Toolbox / GetDragHiliteColor / DrawCode.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-09-11  |  1.9 KB  |  92 lines  |  [TEXT/MPS ]

  1. #include <Windows.h>
  2. #include <QuickDraw.h>
  3. #include <TextUtils.h>
  4. #include <Fonts.h>
  5.  
  6. extern void SetupDragHiliteColor(WindowPtr);
  7.  
  8. /*-------------------------------------------------------------------------------------*/
  9.  
  10. void DrawIt(WindowPtr win)
  11. {
  12.     short         origFont, origSize;
  13.     
  14.     origFont = win->txFont;
  15.     origSize = win->txSize;
  16.     TextFont(helvetica);
  17.     TextFace(bold);
  18.     TextSize(14);
  19.  
  20.     SetupDragHiliteColor(win);
  21.     PaintRect(&(*win).portRect);
  22.     ForeColor(blackColor);
  23.  
  24.     MoveTo(10, 30);
  25.     DrawString("\pThis is the hilite color used for drags");
  26.  
  27.     TextFont(origFont);
  28.     TextSize(origSize);
  29.     TextFace(0);
  30. }
  31.  
  32.  
  33. /*-------------------------------------------------------------------------------------*/
  34.  
  35. pascal void DrawWindowContent(short pixelDepth, short dFlags, GDHandle theDevice, long theWin)
  36. {
  37. #pragma unused (pixelDepth, dFlags, theDevice)
  38.     GrafPtr        savePort;
  39.  
  40.     GetPort(&savePort);
  41.     SetPort((GrafPtr)theWin);
  42.  
  43.     DrawIt((WindowPtr)theWin);
  44.  
  45.     SetPort(savePort);
  46. }
  47.  
  48.  
  49. /*-------------------------------------------------------------------------------------*/
  50.  
  51. void CreateNewWindow(void)
  52. {
  53.     Rect winDimension;
  54.     
  55.     SetRect(&winDimension, 60, 60, 360, 160);
  56.     (void)NewCWindow(0L, &winDimension, "\pSample", true, noGrowDocProc,
  57.                             (WindowPtr)-1L, true, 0L);
  58. }
  59.  
  60.  
  61. /*-------------------------------------------------------------------------------------*/
  62.  
  63. void PreEventLoop(void)
  64. {
  65.     CreateNewWindow();
  66. }
  67.  
  68.  
  69. /*-------------------------------------------------------------------------------------*/
  70.  
  71. void DoUpdate(WindowPtr thisWindow)
  72. {
  73.     static DeviceLoopDrawingUPP    procForDeviceLoop = nil;
  74.  
  75.     SetPort(thisWindow);
  76.  
  77.     if ( procForDeviceLoop == nil )
  78.         procForDeviceLoop = NewDeviceLoopDrawingProc(DrawWindowContent);    
  79.     
  80.     BeginUpdate(thisWindow);
  81.     DeviceLoop(thisWindow->visRgn, procForDeviceLoop, (long)thisWindow, singleDevices);
  82.     EndUpdate(thisWindow);
  83. }
  84.  
  85.  
  86. /*-------------------------------------------------------------------------------------*/
  87.  
  88. void PostEventLoop(void)
  89. {
  90. }
  91.  
  92.